// Author: Gehad
dojo.addOnLoad(function(){
    dojo.connect(dijit.byId("form"), "onSubmit", function(event){
    var form = dijit.byId("form");
    if (!form.validate()) {
        return false;
    }
dojo.stopEvent(event);
var values=form.getValues();
var g=new myGrid();
g.setLayout([
                [{
                field: "pid_val",
                name: "Id"
            },{
                field: "pid_type",
                name: "Type"

            },{
                field: "p_title",
                name: "Title"
            },{
                field: "tit_type",
                name: "Title type"
            },{
                field: "frm_name",
                name: "Format"
            },{
                field: "crt_name",
                name: "Created by"
            },{
                field: "sup_name",
                name: "Supervisor"
            },{
                field: "lng_name",
                name: "Laguage"
            },{
                field: "pub_name",
                name: "Publisher",
		width: "auto"

            },{
                field: "state",
                name: "State",
                width: "120px"
            },{
                field: "auth",
                name: "Authrization",
                 width: "auto"
            }]]);
var url="/productreport/data?status="+values.status+"&createdBy="+values.createdBy+"&authorization="+values.authorization+"&supervisor="+values.supervisor+"&publisher="+values.publisher+"&from="+(values.from==null?'':dojo.date.locale.format(values.from, {datePattern:"yyyy-MM-d", selector: 'date'}))+"&to="+(values.to==null?'':dojo.date.locale.format(values.to, {datePattern:"yyyy-MM-d", selector: 'date'}))+"&submit=submit";
g.setStore(url);
g.createGrid();
g.addGrid('result');
});


        dojo.connect(dojo.byId("add"), "onclick", function(evt){
            var status = dojo.byId("status").nextSibling;
            status = status.value;
            var createdBy = dojo.byId("createdBy").nextSibling;
            createdBy = createdBy.value;
            var authorization = dojo.byId("authorization").nextSibling;
            authorization = authorization.value;
            var supervisor = dojo.byId("supervisor").nextSibling;
            supervisor = supervisor.value;
            var publisher = dojo.byId("publisher").nextSibling;
            publisher = publisher.value;
            var from = dojo.byId("from").nextSibling;
            from = from.value;
            var to = dojo.byId("to").nextSibling;
            to = to.value;
            var querystr = dojo.byId("add").href;

            querystr=querystr+"?status="+status+"&createdBy="+createdBy+
            "&authorization="+authorization+"&supervisor="+supervisor+"&publisher="+publisher+
            "&from="+from+"&to="+to;

            dojo.byId("add").href=querystr;

});
});
